#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000 + 5;
int val[MAXN];
int main()
{
#ifdef LOCAL
    freopen("ADV-303.in", "r", stdin);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n, m; cin >> n >> m;
    for(int i = 0; i < n; ++i)
        cin >> val[i];
    int ans = INT_MIN;
    for(int beg = 0; beg < n; ++beg)
    {
        int t = 0;
        for(int i = 0; i < m; ++i)
        {
            t += val[(beg + i) % n];
        }
        ans = max(ans, t);
    }
    cout << ans << endl;
    return 0;
}